package com.zllkj.mm.api.net;

/**
 * 自定义错误信息，统一处理返回处理
 */
public class HttpTimeException extends RuntimeException {

    public static final int ERROR_PARAMETER =1001;
    public static final int ERROR_SIGN = 1002;

    public static final  int TOKEN_OUT_DATA=2005;
    public static final  int NO_DATA=202011;


    public HttpTimeException(int resultCode) {
        this(getApiExceptionMessage(resultCode));
    }

    public HttpTimeException(String detailMessage) {
        super(detailMessage);
    }

    /**
     * 转换错误数据
     * @param code
     * @return
     */
    private static String getApiExceptionMessage(int code) {
        String message = "";
        switch (code) {
            case NO_DATA:
                message = "无数据";
                break;
            case ERROR_PARAMETER:
                message="参数有误";
                break;
            case ERROR_SIGN:
                message="签名有误";
                break;
            case TOKEN_OUT_DATA:
                message="token已过期";
                break;
            default:
                message = "error";
                break;
        }
        return message;
    }
}

